:root {
  --green: #203c26;
  --white: #ffffff;
  --lightgreen: #2c5234;
  --accent: #8B4513;
  --bg-cream: #f4f4f2;
}

.header {
  background-color: var(--white);
  border-bottom: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  margin-bottom: 30px;
}

.main-container {
  background-color: #edeef0;
  display: flex;
  flex-direction: column;
  min-height: auto;
}

#game-board {
  display: grid;
  grid-template-rows: repeat(var(--grid-size), var(--cell-size));
  grid-template-columns: repeat(var(--grid-size), var(--cell-size));
  background-color: var(--green);
  gap: var(--cell-gap);
  border-radius: 8px;
  padding: var(--cell-gap);
  position: relative;
  margin: 20px auto;
  width: min-content;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  --cell-size: 15vmin; 
  --cell-gap: 1.5vmin;
  touch-action: none;
  overscroll-behavior: contain;
}

.content-container {
  display: block;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.game-card {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 900px;
  padding: 20px;
}

.score-container {
    background: var(--lightgreen);
    padding: 10px 25px;
    border-radius: 3px;
    color: var(--white);
    text-align: center;
    min-width: 100px;
    display: inline-block;
    margin-bottom: 20px;
}

.score-label {
    font-size: 13px;
    font-weight: bold;
    color: #eee4da;
}

#current-score {
    font-size: 25px;
    font-weight: bold;
    display: block;
}

.cell {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.tile {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 4px;
  top: calc(var(--y) * (var(--cell-size) + var(--cell-gap)) + var(--cell-gap));
  left: calc(var(--x) * (var(--cell-size) + var(--cell-gap)) + var(--cell-gap));
  font-weight: bold;
  font-size: 1.8rem;
  background-color: hsl(var(--hue, 30), 40%, var(--background-lightness));  
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  
  animation: show 200ms ease-in-out;
  transition: 100ms ease-in-out;
}

.tile {
  --background-lightness: 90%;
}

.footer {
  margin-top: 30px;
}

.alert {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    width: 100%;
}

.alert:last-child {
    margin-bottom: 0;
}

.alert.hide {
    opacity: 0;
}

[data-alert-container] {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; 
    width: 100%;
}

.leaderboard-card {
    background: var(--white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    width: 300px;
    text-align: center;
    border-top: 6px solid var(--green);
    animation: popIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.leaderboard-header {
    color: var(--green);
    font-size: 1.6rem;
    margin: 0 0 15px 0;
    font-weight: 800;
    text-transform: uppercase;
    width: 100%;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    min-width: 200px;
    padding: 12px 5px;
    border-bottom: 1px solid #f4f4f4;
    font-size: 1.1rem;
    box-sizing: border-box;
}

.rank-initials {
    font-weight: bold;
    color: #444;
}

.high-score {
    color: var(--green);
    font-weight: 800;
}

.leaderboard-btn {
    display: block;
    margin: 20px 0 0 0;
    padding: 12px 0;
    background-color: var(--green);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    width: 180px; 
    text-align: center;
    transition: background 0.2s ease, transform 0.1s;
}

.leaderboard-btn:hover {
    background-color: var(--lightgreen);
    transform: scale(1.05);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.alert {
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.leaderboard-alert h3 {
    font-family: Georgia, 'Times New Roman', Times, serif;
    color: #776e65;
}

@keyframes show {
  0% {
    opacity: .5;
    transform: scale(0);
  }
}

/* Responsive adjustments for mobile */
@media (max-width: 600px) {
  #game-board {
    --cell-size: 20vw;
    --cell-gap: 2vw;
  }
  
  .tile {
    font-size: 1.5rem;
  }

  .game-card {
    overflow: hidden;
  }
}
